package src.model.gameWorld;

import src.event.*;
import src.event.events.UpdateView;

/**
 * <b>Overview</b><br>
 * <p>This class is responsible for listening for update events and 
 * relaying the information to the current player.</p>
 * <br><br>
 * <b>Responsibilites</b><br>
 * <p>Relaying update evnts to the current player</p>
 * <br><br>
 * <b>Collaborators</b>
 * <ul>
 * <li>CurrentPlayer - Subcontactor</li>
 * <li>PlayerMap - Subcontractor</li>
 * </ul>
 * <br><br>
 * <b>Implementor</b> - Brent<br>
 * <b>Tester</b> - Tim<br>
 * 
 * @author Brent
 *
 */
public class UpdateViewEventListener implements EventListener<UpdateView>
{
	private CurrentPlayer myCP;

	public UpdateViewEventListener(CurrentPlayer cp)
	{
		myCP = cp;
		GameWorldEventHandler.getReference().getUpdateViewEventHandler().regesterListener(this);
	}

	public boolean eventCallback(UpdateView e)
	{
		PlayerMap currentMap = myCP.getCurrentPlayer().getPlayerMap();

		currentMap.ReduceVision(e.getOldPosition(), e.getViewRadius());
		currentMap.ExpandVision(e.getNewPosition(), e.getViewRadius());

		currentMap.UpdateMap();

		return true;
	}
}
